/**
 * @example huolicai://toapp?p={“jp_toPage”: “定期投资详情”, “jp_toUrl”:”jp_deadInvestDetail”,”param”:{“pid”:”126”}}
 * @author huolicai
 */
var app = {
    // 跳转
    forwardUrl: "huolicai://forward?p=",
    /**
     *
     * @param name
     * @param url
     * @param param
     * @param toType
     * @returns {{jp_toPage: *, jp_toUrl: *, jp_toType: *, param: *}}
     */
    setQuery(name, url, param, toType) {
        if (toType) {
            toType = toType
        } else {
            toType = 'native'
        }
        var obj = {
            "jp_toPage": name,
            "jp_toUrl": url,
            "jp_toType": toType,
            "param": param
        };
        return JSON.stringify(obj)
    },
    /**
     *
     * @param name
     * @param url
     * @param param
     * @param toType
     * @returns {Window}
     */
    pages: {
        messagelist: {
            toPage: "消息列表",
            toType: "native",
            toUrl: "jp_messagelist",
        },
        noticelist: {
            toPage: "公告列表",
            toType: "native",
            toUrl: "jp_noticelist",
        },
        sign: {
            toPage: "签到",
            toType: "native",
            toUrl: "jp_sign",
        },
        myAsset: {
            toPage: "我的资产",
            toType: "native",
            toUrl: "jp_myAsset",
        },
        myTicket: {
            toPage: "我的火券",
            toType: "native",
            toUrl: "jp_myTicket",
        },
        shoppingmall: {
            toPage: "积分商城",
            toType: "native",
            toUrl: "jp_shoppingmall",
        },
        actionCenter: {
            toPage: "活动中心",
            toType: "native",
            toUrl: "jp_actionCenter",
        },
        recharge: {
            toPage: "充值",
            toType: "native",
            toUrl: "jp_recharge",
        },
        withdraw: {
            toPage: "提现",
            toType: "native",
            toUrl: "jp_withdraw",
        },
        aboutUs: {
            toPage: "关于我们",
            toType: "native",
            toUrl: "jp_aboutUs",
        },
        profileCenter: {
            toPage: "个人中心",
            toType: "native",
            toUrl: "jp_profileCenter",
        },
        tradingRecord: {
            toPage: "交易记录",
            toType: "native",
            toUrl: "jp_tradingRecord",
        },
        address: {
            toPage: "收货地址",
            toType: "native",
            toUrl: "jp_address",
        },
        goback: {
            toPage: "返回上一页",
            toType: "native",
            toUrl: "jp_goback",
        },
        gobackToRoot: {
            toPage: "返回到根目录",
            toType: "native",
            toUrl: "jp_gobackToRoot",
        },
        login: {
            toPage: "登录",
            toType: "native",
            toUrl: "jp_login",
        },
        register: {
            toPage: "返回到根目录",
            toType: "native",
            toUrl: "jp_register",
        },
        objectList: {
            toPage: "散标列表",
            toType: "native",
            toUrl: "jp_objectList",
        },
        debtList: {
            toPage: "债券列表",
            toType: "native",
            toUrl: "jp_debtList",
        },
        objectDetail    : {
            toPage: "标的详情",
            toType: "native",
            toUrl: "jp_objectDetail",
        },
        debtDetail: {
            toPage: "债权详情",
            toType: "native",
            toUrl: "jp_debtDetail",
        },
        contactService: {
            toPage: "联系客服",
            toType: "native",
            toUrl: "jp_contactService",
        },
        loanDetail: {
            toPage: "出借详情",
            toType: "native",
            toUrl: "jp_loanDetail",
        },
        rechargeFinished: {
            toPage: "充值完成",
            toType: "native",
            toUrl: "jp_rechargeFinished",
        },
        gotoMyBankCard: {
            toPage: "我的银行卡",
            toType: "native",
            toUrl: "jp_gotoMyBankCard"
        },
        bestLoanDetail: {
            toPage: "出借详情",
            toType: "native",
            toUrl: "jp_bestLoanDetail"
        }

    },
    get: function (name, url, param, toType) {
        // 新开 webview 打开h5
        return this.forwardUrl + this.setQuery(name, url, param, toType);
    },
    getMessageList: function () {
        // 消息列表
        return this.forwardUrl + this.setQuery(this.pages.messagelist.toPage, this.pages.messagelist.toUrl, JSON.stringify({}));
    },
    getNoticeList: function () {
        // 公告列表
        return this.forwardUrl + this.setQuery(this.pages.noticelist.toPage, this.pages.noticelist.toUrl, JSON.stringify({}));
    },
    getSign: function () {
        // 签到
        return this.forwardUrl + this.setQuery(this.pages.sign.toPage, this.pages.sign.toUrl, JSON.stringify({}));
    },
    getMyAsset: function () {
        // 我的资产
        return this.forwardUrl + this.setQuery(this.pages.myAsset.toPage, this.pages.myAsset.toUrl, JSON.stringify({}));
    },
    getMyTicket: function () {
        // 我的火券
        return this.forwardUrl + this.setQuery(this.pages.myTicket.toPage, this.pages.myTicket.toUrl, JSON.stringify({}));
    },
    getShoppingMall: function () {
        // 积分商城
        return this.forwardUrl + this.setQuery(this.pages.shoppingmall.toPage, this.pages.shoppingmall.toUrl, JSON.stringify({}));
    },
    getActionCenter: function () {
        // 活动中心
        return this.forwardUrl + this.setQuery(this.pages.actionCenter.toPage, this.pages.actionCenter.toUrl, JSON.stringify({}));
    },
    getRecharge: function () {
        // 充值
        return this.forwardUrl + this.setQuery(this.pages.recharge.toPage, this.pages.recharge.toUrl, JSON.stringify({}));
    },
    getWithdraw: function () {
        // 提现
        return this.forwardUrl + this.setQuery(this.pages.withdraw.toPage, this.pages.withdraw.toUrl, JSON.stringify({}));
    },
    getAboutUs: function () {
        // 关于我们
        return this.forwardUrl + this.setQuery(this.pages.aboutUs.toPage, this.pages.aboutUs.toUrl, JSON.stringify({}));
    },
    getProfileCenter: function () {
        // 个人中心
       return this.forwardUrl + this.setQuery(this.pages.profileCenter.toPage, this.pages.profileCenter.toUrl, JSON.stringify({}));
    },
    getTradingRecord: function () {
        // 交易记录
        return this.forwardUrl + this.setQuery(this.pages.tradingRecord.toPage, this.pages.tradingRecord.toUrl, JSON.stringify({}));
    },
    getAddress: function () {
        // 收货地址
        return this.forwardUrl + this.setQuery(this.pages.address.toPage, this.pages.address.toUrl, JSON.stringify({}));
    },
    getGoBack: function () {
        // 返回上一页
        return this.forwardUrl + this.setQuery(this.pages.goback.toPage, this.pages.goback.toUrl, JSON.stringify({}));
    },
    getGoBackToRoot: function () {
        // 返回到根目录 app首页
        return this.forwardUrl + this.setQuery(this.pages.gobackToRoot.toPage, this.pages.gobackToRoot.toUrl, JSON.stringify({}));
    },
    getLogin: function () {
        // 登录
        return this.forwardUrl + this.setQuery(this.pages.login.toPage, this.pages.login.toUrl, JSON.stringify({}));
    },
    getRegister: function () {
        // 注册
        return this.forwardUrl + this.setQuery(this.pages.register.toPage, this.pages.register.toUrl, JSON.stringify({}));
    },
    getObjectList: function () {
        // 散标列表
        return this.forwardUrl + this.setQuery(this.pages.objectList.toPage, this.pages.objectList.toUrl, JSON.stringify({}));
    },
    getDebtList: function () {
        // 债权列表
        return this.forwardUrl + this.setQuery(this.pages.debtList.toPage, this.pages.debtList.toUrl, JSON.stringify({}));
    },
    getObjectDetail: function (pid) {
        // 标的详情
        return this.forwardUrl + this.setQuery(this.pages.objectDetail.toPage, this.pages.objectDetail.toUrl, JSON.stringify({'pid':pid}));
    },
    getDebtDetail: function (pid) {
        // 债权详情
        return this.forwardUrl + this.setQuery(this.pages.debtDetail.toPage, this.pages.debtDetail.toUrl, JSON.stringify({'pid':pid}));
    },
    getContactService: function(){
        //联系客服
        return this.forwardUrl + this.setQuery(this.pages.contactService.toPage, this.pages.contactService.toUrl, JSON.stringify({}));
    },
    getloanDetail: function(tid){
        // 出借详情
        return this.forwardUrl + this.setQuery(this.pages.loanDetail.toPage, this.pages.loanDetail.toUrl, JSON.stringify({'tid':tid}));
    },
    getRechargeFinished: function(){
        // 充值完成
        return this.forwardUrl + this.setQuery(this.pages.rechargeFinished.toPage, this.pages.rechargeFinished.toUrl, JSON.stringify({}));
    },
    getGotoMyBankCard: function(){
        // 我的银行卡
        return this.forwardUrl + this.setQuery(this.pages.gotoMyBankCard.toPage, this.pages.gotoMyBankCard.toUrl, JSON.stringify({}));
    },
    getBestLoanDetail: function(tid){
        // 优选出借详情
        return this.forwardUrl + this.setQuery(this.pages.bestLoanDetail.toPage, this.pages.bestLoanDetail.toUrl, JSON.stringify({'tid':tid}));
    }
};

export default app